{template 'common/header'}

<div class="mii-box text-center">
    <div class="sobox">
        <input type="text"  name="sokey" class="sokey" placeholder="请输入查询值">
    <!-- <button class="sobt submit center-block"  type="submit">提交</button> -->
<!--     <div class="input-group "> -->
        <!-- <input type="text"  name="sokey" class="sokey" placeholder="请输入订单编号/会员姓名/手机号码"> -->
        
        <button type="button" class="btn dropdown-toggle submit" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">查询条件 <span class="caret"></span></button>
        <ul class="dropdown-menu dropdown-menu-right">
          <li><a id="soorderid" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'soorderid'));}&key=">订单ID</a></li>
          <li role="separator" class="divider"></li>              
          <li><a id="somemberid" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'somemberid'));}&key=">会员ID</a></li>
          <li role="separator" class="divider"></li> 
          <li><a id="somembername" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'somembername'));}&key=">会员名称</a></li>
         <li role="separator" class="divider"></li> 
          <li><a id="somembermobile" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'somembermobile'));}&key=">会员手机号</a></li>          
          <li role="separator" class="divider"></li> 
          <li><a id="sopaybook" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'sopaybook'));}">支付预约</a></li>
          <li role="separator" class="divider"></li> 
          <li><a id="sobook" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'sobook'));}">免费预约</a></li>
        </ul>
    </div>
</div>
<!-- </div> -->
{if $order}
{loop $order $k $o}
    <div class="list_th">
        <div class="td" style=" width:20%;">
         <div class="left_padding"><b>订单编号:</b>{$o['orderid']}</div>
        </div>
        <div class="td text-center" style=" width:30%;"><b>创建时间:</b>{php echo date('Y-m-d H:i:s',$o['addtime'])} </div>
        <div class="td text-center" style=" width:30%;"><b>预约时间:</b>{php echo date('Y-m-d H:i:s',dejson($o['details'],'booktime'))} </div>
        <div class="clear"></div>
    </div>
    <div class="list_tr link_bk">
            <div class="td text-center padding" style=" width:10%;">
            	<img class="goods-img" src="{$_W['attachurl']}{$o['titlepic']}">
                <div class="clear"></div>
            </div>
            <div class="td text-center border-r" style=" width:10%;line-height: 50px;" >
            	<span>项目名称</span>
            	<span class="info">{php echo dejson($o['details'],'goodsname')}</span> 
            </div>
            <div class="td text-center" style=" width:10%;line-height: 50px;" >
            	<span class="title">顾客姓名</span>
            	<span class="info">{php echo dejson($o['details'],'uname')}</span> 
            </div>            
            <div class="td text-center" style=" width:10%; line-height: 50px;" >    
            	<span>技师名称</span>
            	<span class="info">{php echo dejson($o['details'],'techname')}</span> 
            </div> 
            <div class="td text-center" style=" width:8%; line-height: 50px;" >
            	<span>预定类型</span>
                {if $o['order_type']=='2'}
            	<span class="ordertype ordertype-pay">支付预约</span> 
                {else if $o['order_type']=='1'}
                <span class="ordertype ordertype-online">免费预约</span>
                {else}
                <span class="ordertype ordertype-online">其他类型</span>
                {/if}     
            </div>
            <div class="td text-center" style=" width:10%; line-height: 50px;" >
                <span>在线支付</span>
                <span class="info">¥ {$o['pay_money']}</span>      
            </div>             
            <div class="td text-center" style=" width:10%; line-height: 50px;" >
                <span>到店需付</span>
                <span class="info">¥ {php echo $o['goods_money']-$o['pay_money']}</span>      
            </div>            
            <div class="td text-center" style=" width:10%;line-height: 50px;" >
            	<span>订单状态</span>
                {if $o['is_ok']=='0'}
            	<span class="info ordertype isoff">未完成</span>
                {else if $o['is_ok']}
                <span class="info ordertype isok">已完成</span>    
                {/if}
            </div>                                                  
            <div class="td edit text-center" style=" width:22%;">   
                <div class="list_right btn">
                    <a href="{php echo $this->createWebUrl('order_details',array('oid'=>$o['oid']));}">详情</a>
                    <a class="green isok" oid="{$o['oid']}" sid ="{$o['is_ok']}" >确认完成</a>
                    <a class="gray delete" did="{$o['oid']}" bid ="{$o['book_id']}">删除</a>                    
                </div>
            </div>
            <div class="clear"></div>
        </div>
 <div class="list_tr gl"></div> 
 {/loop}
 {else}
 {/if}  
{if $pager}       
<div class="list_tr">    
<div class="text-center">
  {php echo $pager;}
</div> 
</div>
{else}
{/if}
<style type="text/css">

</style>
<link href="{MODULE_URL}template/web/css/classlist.css" rel="stylesheet" type="text/css">
<link href="{MODULE_URL}template/web/css/miistye.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="{MODULE_URL}public/css/Toast.css">
<script src="{MODULE_URL}public/js/Toast.js"></script> 
<script type="text/javascript">
	$(document).ready(function(){
        //删除
        $(document).on('click','.delete', function () {
          if(!confirm("确定要删除该订单吗！删除不可恢复！")){                
               window.event.returnValue=false;
           }else{
               $.ajax({
                   url:"{php echo $this->createWebUrl('orderdel');}&version_id="+"{$_GPC['version_id']}",
                   data:{did:$(this).attr('did'),bid:$(this).attr('bid')},
                   dataType:"json",
                   type:"post",
                  success:function(res){
                     if(res.status== 1){
                         mqToast({type:1,context: res.msg}); 
                          setTimeout(function(){
                            window.location.reload();
                          },1000); 
                         return false;
                     }else{
                         mqToast({type:1,context: res.msg}); 
                         return false;
                     }
                  }
                })                    
           }        
        }); 
        //确认完成
        $(document).on('click','.isok',function(){
            var sid = $(this).attr('sid');
            var oid = $(this).attr('oid');
            if(sid !=1){
                if(!confirm('您确认已完成该订单吗？')){
                    window.event.returnValue = false;
                }else{
                    $.ajax({
                        url:"{php echo $this->createWebUrl('orderisok');}&version_id="+"{$_GPC['version_id']}",
                        data:{oid:oid,sid:sid},
                        dataType:"json",
                        type:"post",
                        success:function(res){
                            if(res.status==1){
                                mqToast({type:1,context: res.msg});
                                  setTimeout(function(){
                                    window.location.reload();
                                  },2000);
                            }else{
                                mqToast({type:1,context: res.msg});
                            }
                        }
                    })
                }
            }else{
                mqToast({type:1,context: '该订单已完成'});
            }
        })

	});
    //so
    // $(document).on('click','.sobt',function(){
    //     var sokey = $.trim($('.sokey').val());
    //     if(sokey==''){
    //         mqToast({type:1,context:'请输入搜索值'});
    //         return false;
    //     }else{
    //         var URL= "{php echo $this->createWebUrl('soorder');}"+"&sokey="+sokey;
    //         window.location.href = URL;
    //     }
    // })
    $('#soorderid').on("click",function(){
         var toSearchPage = $(this).attr('data-href');
         var key = $.trim($('.sokey').val());
         if(key==''){
            mqToast({type:1,context: '请输入要搜索的订单编号'});  
            return false
         }
         if(isNaN(key)){
            mqToast({type:1,context: '请输入纯数字'});
         }else{
            window.location.href = toSearchPage + key;
         }
    })
    $('#somemberid').on("click",function(){
         var toSearchPage = $(this).attr('data-href');
         var key = $.trim($('.sokey').val());
         if(key==''){
            mqToast({type:1,context: '请输入要搜索的会员id'});  
            return false
         }else{
            window.location.href = toSearchPage + key;
         }
    })
    $('#somembername').on("click",function(){
         var toSearchPage = $(this).attr('data-href');
         var key = $.trim($('.sokey').val());
         if(key==''){
            mqToast({type:1,context: '请输入要搜索的会员名称'});  
            return false
         }else{
            window.location.href = toSearchPage + key;
         }
    })
    $('#somembername').on("click",function(){
         var toSearchPage = $(this).attr('data-href');
         var key = $.trim($('.sokey').val());
         if(key==''){
            mqToast({type:1,context: '请输入要搜索的会员名称'});  
            return false
         }else{
            window.location.href = toSearchPage + key;
         }
    })
    $('#somembermobile').on("click",function(){
         var toSearchPage = $(this).attr('data-href');
         var key = $.trim($('.sokey').val());
         if(key==''){
            mqToast({type:1,context: '请输入要搜索的会员手机号'});  
            return false
         }else{
            window.location.href = toSearchPage + key;
         }
    })

    $('#sopaybook').on("click",function(){
        var toSearchPage = $(this).attr('data-href');
        window.location.href = toSearchPage;
    })
    $('#sobook').on("click",function(){
        var toSearchPage = $(this).attr('data-href');
        window.location.href = toSearchPage
    })        
</script>
{template 'common/footer'}